{php}
$unit_arr=['year'=>'年','month'=>'月','day'=>'天'];
$unit=__($unit_arr[$pay_config['renew_unit']])
{/php}

<!-- Header Carousel -->
<header id="myCarousel" class="carousel slide">


    <!-- Wrapper for slides -->
    <div class="carousel-inner">
        <div class="item active">
            <a href="javascript:" target="_blank">
                <div class="fill" style="background-image:url('');"></div>
                <div class="carousel-body">
                    <div class="container">
                        <h2 class="display-4 text-white">{:__("在线续费")}</h2>
                    </div>
                </div>
            </a>
        </div>
    </div>
</header>

<!-- Page Content -->
<div class="container">

    <div class="row">

        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4><i class="fa fa-wpforms"></i> {:__('合同信息')}</h4>
                </div>
                <div class="panel-body">
                    <p>{:__("合同编号")}：{$row['number']}</p>
                    <p>{:__("合同名称")}：{$row['name']}</p>
                    <p>{:__("合同金额")}：{$row['money']}</p>
                    <p>{:__("始止日期")}：{:datetime($row['start_time'],'Y/m/d H:i')} ~ {:datetime($row['end_time'],'Y/m/d H:i')} </p>
                    {php}
                    $product_name='暂无说明';
                    if($row->product){
                        $product_name=$row->product[0]['name'];
                        $pcount=count($row->product);
                        $pcount>1?$product_name.="等{$pcount|htmlentities}样商品":'';
                    }

                    {/php}
                    <p>{:__("服务/产品")}：{$product_name|htmlentities} </p>
                    <div class="">
                        <p style="color: red;">{:__("在您支付之前,请仔细阅读以下协议内容")}：</p>
                        <i class="fa fa-wpforms"></i> {:__('协议')}：<a href="javascript:openxyi();"><span style="color: red"> 点击查阅</span></a>
                        <div id="xieyi" style="display: none;padding: 10px" >

                            {$pay_config['r_agreement']}


                        </div>
                    </div>

                </div>
            </div>
        </div>

        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h4><i class="fa fa-wechat"></i> {:__('支付')}</h4>
                </div>
                <div class="panel-body">
                    <form method="get" action="{:addon_url('facrm/order/submit')}">
                        <div style="line-height: 40px;">
                        <span class="input-group">
                            {:__("续费金额")}：
                            <span class="text-danger" id="renew_moeny_text">￥{$row['renewmoeny']} | {$pay_config['renew_day']}{:$unit}</span>
                        </span>
                        </div>


                        <div style="line-height: 40px;">
                        <span class="input-group">
                             {:__("续费数量")}：


                            <span class="input-group-addon" style="padding:0;width:100px;border:none;">

                                <center>
                                    <input type="text" class="spinnerExample" name="number"/>
                                </center>
                            </span>
                        </span>
                        </div>
                        <p>{:__("请选择支付方式")}</p>

                        <input type="hidden" name="pay_token" value="{:input('pay_token','','strip_tags,htmlentities')}">
                        <input type="hidden" name="ordertype" value="renew">
                        <input type="hidden" name="paytype" value="">
                        {php}
                        $pinfo = get_addon_config('epay');
                        {/php}
                        {if $pinfo['wechat']['mch_id']}
                        <button data-type="wechat"  type="button" class="btn btn-success btn-pay"><i class="fa fa-wechat"></i> 微信支付</button>
                        {/if}
                        {if $pinfo['alipay']['app_id']}
                        <button data-type="alipay"  type="button" class="btn btn-info btn-pay"><i class="fa fa-alipay"></i> 支付宝支付</button>
                        {/if}

                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- /.row -->

    <hr>

</div>
<link rel="stylesheet" href="__CDN__/assets/addons/facrm/css/spinner.css">
<script src="__CDN__/assets/addons/facrm/js/jquery.spinner.js"></script>
<script>
    $('form .btn-pay').click(function(){
        var paytype=$(this).data('type');
        $('input[name="paytype"]').val(paytype);
        $("form").submit();
    });
    function openxyi() {
        var index = layer.open({
            type: 1,
            title:'协议内容',
            content: $("#xieyi"),
            area: ['320px', '195px']
            ,btn: ['确定并关闭']
            ,yes: function(index1, layero){
                layer.close(index);
            }
        });
        layer.full(index);
    }

    total(1);
    $(function() {
        $(".decrease,.increase").on("click", function () {
            total($(".spinnerExample").val());
        });
        $(".spinnerExample").bind('input propertychange', function () {
            total($(".spinnerExample").val());
        })
    })
    function total(number){
        if(!isNaN(number)){
            var renew_moeny=parseFloat("{$row['renewmoeny']}")*number;
            $('#renew_moeny_text').text("￥"+renew_moeny+" | "+number+"{:$unit}");
        }
        return false;
    }


    $('.spinnerExample').spinner({max:"{$pay_config['renew_max']}"});

</script>










